
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<span style="font-size:18px;">
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="attendance/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="attendance/css/commonly-used-show.css" />
    <script type="text/javascript" src="attendance/js/jquery.min.js"></script>
    <script type="text/javascript" src="attendance/js/bootstrap.js" ></script>

    <title>假条审批</title>

</head>

<body class="mybody">

<jsp:include page="theTopMenuTeacher.jsp" />



<div class="container-fluid">
    <div class="row">


        <div class="col-md-12">
            <div class="col-md-12">
                    <div class="panel panel-primary">
                        <div class="panel-body">
                            <div class="alert alert-success">


                                <div>
        <h3 style="text-align: center">请假审批</h3>
        <hr style="filter: alpha(opacity=100,finishopacity=0,style=3)" width="100%" color="#6f5999" size="3"/>

        <div id="personal_user" style="margin-left: 80px;">

            <div class="form-group same-line">
                <label for="user_name">姓名：</label>
                <input type="text" disabled="disabled" id="user_name" class="form-control edit" placeholder="请输入姓名" v-model="user_name">
            </div>

            <div class="form-group same-line-left">
                <label for="leave_type">请假类型：</label>
                <select class="form-control edit" disabled="disabled" title="请选择" id="leave_type" data-live-search="true" data-size="5">
                    <option value="" disabled selected hidden>请选择</option>
                    <option value="0">病假</option>
                    <option value="1">事假</option>
                    <option value="2">其他</option>
                </select>
            </div>

            <div class="form-group same-line-left">
                <label for="start_time">开始时间：</label>
                <input type="date" disabled="disabled" id="start_time" class="form-control edit" placeholder="请选择" v-model="start_time">
            </div>

            <div class="form-group same-line">
                <label for="end_time">结束时间：</label>
                <input type="date" disabled="disabled" id="end_time" class="form-control edit" placeholder="请选择" v-model="end_time">
            </div>

            <div class="form-group same-line-left">
                <label for="type_approval">审批类型：</label>
                <select class="form-control edit" title="请选择" id="type_approval" data-live-search="true" data-size="5">
                    <option value="" disabled selected hidden>请选择</option>
                    <option value="0">同意</option>
                    <option value="1">不同意</option>
                </select>
            </div>


            <div class="form-group same-line-left">
                <label>XXXX</label>
                <input type="text" disabled="disabled" class="form-control edit" >
            </div>

            <div class="form-group same-line">
                <label for="reason_leave">请假原因：</label>
                <textarea id="reason_leave" disabled="disabled" style="height: 150px" class="form-control edit" placeholder="请输入请假原因" v-model="reason_leave"></textarea>

            </div>

            <div class="form-group same-line-left">
                <label for="approval_note">审批备注：</label>
                <textarea id="approval_note" style="height: 150px" class="form-control edit" placeholder="请输入审批备注" v-model="approval_note"></textarea>
            </div>

        </div>

        <div class="text-center same-line-clear">
            <div class="form-group">
                <input type="button" value="提交" class="btn btn-primary" onclick="present()">
                <input type="reset" value="重置" class="btn btn-danger interval" onclick="reset()">
            </div>

            <div>
                <label id="user_null" style="color: red"></label>
            </div>
        </div>

    </div>


                            </div>
                        </div>
                    </div>
                </div>
        </div>



    </div>

 </div>





<script type="text/javascript">
    var userdt = JSON.parse(sessionStorage.getItem("user"));
    var userNull = document.getElementById("user_null");
    if (userdt.result.userName != null){
        $("#usname").text(userdt.result.userName);
    }else {
        $("#usname").text(userdt.result.userLoginName);
    }


    window.onload = function(){
        leaveInfo();
    }

    function leaveInfo(){
        var postUrl = "${pageContext.request.contextPath}/member/selectByPrimaryKey";

        var str = {
            "id": "${param.id}"
        };

        $.ajax({
            type:"post",
            url:postUrl,
            headers: {
                "Content-Type":"application/json"
            },
            data:JSON.stringify(str),
            contentType: "application/json; charset=utf-8",
            dataType:"json",
            success:function(data){
                if (data.status == "0"){
                    userNull.innerHTML = data.msg;
                    //alert("获取用户信息出错")
                }else {
                    $("#user_name").val(data.result.userName);
                    $("#leave_type").val(data.result.leaveType);
                    $("#reason_leave").val(data.result.reasonLeave);
                    $("#start_time").val(data.result.startTime);
                    $("#end_time").val(data.result.endTime);
                    if(data.result.typeApproval != null){
                        $("#type_approval").val(data.result.typeApproval);
                    }
                    if(data.result.approvalNote != null){
                        $("#approval_note").val(data.result.approvalNote);
                    }

                }

            },
            error:function(xhr,state,errorThrown){
                //alert("发生网络错误，错误码为：" + xhr.status)
                location.href = "${pageContext.request.contextPath}/error";
            }
        });

    }

    function present(){
        var typeApproval = $("#type_approval").val();
        var approvalNote = $("#approval_note").val();

        if ($.isEmptyObject(typeApproval)){
            userNull.innerHTML = "审批类型不能为空";
            return false;
        }

        var postUrl = "${pageContext.request.contextPath}/member/teacherUpdateByPrimaryKeySelective";
        var str = {
            "id": "${param.id}",
            "typeApproval": typeApproval,
            "approvalNote": approvalNote
        };

        $.ajax({
            type:"post",
            url:postUrl,
            headers: {
                "Content-Type":"application/json"
            },
            data:JSON.stringify(str),
            contentType: "application/json; charset=utf-8",
            dataType:"json",
            success:function(data){
                if (data.status == "0"){
                    userNull.innerHTML = data.msg;
                }else {
                    location.href = "${pageContext.request.contextPath}/askForLeaveApproval";
                }

            },
            error:function(xhr,state,errorThrown){
                //alert("发生网络错误，错误码为：" + xhr.status)
                location.href = "${pageContext.request.contextPath}/error";
            }
        });
    }
</script>

</body>
</html>
</span>